In [1]:
def square(num):
result = num**2
return result
In [2]:
square(4)
Out[2]:
In [5]:
def square(num):
return num**2
In [6]:
square(4)
Out[6]:
In [7]:
def square(num): return num**2
In [8]:
square(2)
Out[8]:
In [9]:
lambda num: num**2
Out[9]:
In [10]:
sq = lambda num: num**2
In [11]:
sq(5)
Out[11]:
In [12]:
even = lambda num: num%2 == 0
In [13]:
even(4)
Out[13]:
In [14]:
even(3)
Out[14]:
In [15]:
first = lambda s: s[0]
In [16]:
first("aggdg")
Out[16]:
In [17]:
rev = lambda s: s[::-1]
In [18]:
rev("hello")
Out[18]:
In [19]:
def adder(x, y):
return x + y
In [20]:
adder(2, 3)
Out[20]:
In [21]:
adderlam = lambda x, y: x + y
In [22]:
adderlam(2, 4)
Out[22]:
In [ ]: